package com.kakame.codenews.base.thymeleaf.dialect;

import java.util.HashSet;
import java.util.Set;

import org.thymeleaf.dialect.AbstractProcessorDialect;
import org.thymeleaf.processor.IProcessor;
import org.thymeleaf.standard.StandardDialect;
import org.thymeleaf.standard.processor.StandardXmlNsTagProcessor;
import org.thymeleaf.templatemode.TemplateMode;

import com.kakame.codenews.base.thymeleaf.processor.RecentlyDateProcessor;

/**
 * <pre>
 * <b>desc:</b> 日期格式化标签类，如将28日格式化成2天前<br>
 *              使用方式：&lt;recdate:format time = "..."/&gt;
 * <b>auth:</b> ex-hejm
 * <b>date:</b> 2018年7月30日 下午3:07:16
 * </pre>
 */
public class RecentlyDateDialect extends AbstractProcessorDialect{
 
    private static final String PREFIX = "recdate";   // 定义方言前缀
    private static final String NAME = "format";     // 定义方言名称
    
    public RecentlyDateDialect() {
        super(NAME, PREFIX, StandardDialect.PROCESSOR_PRECEDENCE + 1);
    }
    /*
     * 
     * 元素处理器：“matter”标签。
     */
    public Set<IProcessor> getProcessors(final String dialectPrefix) {
        Set<IProcessor> processors = new HashSet<IProcessor>();
        processors.add(new RecentlyDateProcessor(dialectPrefix, NAME));//添加我们定义的标签
        
        processors.add(new StandardXmlNsTagProcessor(TemplateMode.HTML, dialectPrefix));
        return processors;
    }
}